<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>巴巴快巴-定时器</title>
    <div th:replace="footer :: resource"></div>
    <link rel="stylesheet" type="text/css" th:href="@{/css/main/main.css}"/>
    <script type="text/javascript" th:src="@{/js/main/main.js}"></script>
</head>
<body class="easyui-layout">
<!-- 顶部 -->
<div class="ui-header" data-options="region:'north',border:false" style="height:40px;overflow: hidden;">
    <h1>巴巴快巴定时器项目</h1>
    <div class="ui-login">
        <div class="ui-login-info">
            欢迎 <span class="orange" th:text="${user.nickName}"></span>
            <a class="logout-btn" href="/adminLogout">退出</a>
        </div>
    </div>
</div>
<!-- 左侧菜单 -->
<div data-options="region:'west',split:true,title:'菜单栏导航'" style="width:200px">
    <div id="sm" style="width:193px" data-options="border:false,animate:false"></div>
</div>
<!-- 中间内容页面 -->
<div data-options="region:'center'">
    <div class="easyui-tabs" id="tab-box" data-options="fit:true,border:false">
    </div>
</div>
<!-- 底部 -->
<div data-options="region:'south',border:false" style="overflow:hidden;">
    <div class="panel-header" style="border: none;text-align: center;">CopyRight &copy; 2020 nobi 版权所有</div>
</div>
<script type="text/javascript">
    $.ajax({
        url: "/admin/getMenu",
        type: "POST",
        dataType: 'json',
        success: function (data) {
            $('#sm').sidemenu({
                data: data,
                onSelect: function (node) {
                    var url = node.attributes.url;
                    var title = node.text;
                    if (url != null && url !== "") {
                        addTab(title, url);
                    }
                }
            });
        }
    });

    function addTab(title, url) {
        var boxId = '#tab-box';
        if ($(boxId).tabs('exists', title)) {
            var tab = $(boxId).tabs('getTab', title);
            var index = $(boxId).tabs('getTabIndex', tab);
            $(boxId).tabs('select', index);
        } else {
            var content = "<iframe scrolling='auto' frameborder='0' src='" + url + "' style='display:block;width:100%; height:100%'></iframe>";
            $(boxId).tabs('add', {
                title: title,
                content: content,
                closable: true
            });
        }
    }

</script>
</body>